package com.njitweb.controller;

import com.njitweb.pojo.Goods;
import com.njitweb.service.GoodService;
import com.njitweb.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/good")
public class GoodController {

    @Autowired
    private GoodService goodService;

    @PostMapping("/addGood")
    public Result addGoods(@RequestBody Goods good) {
        goodService.addGoods(good);
        return Result.success("添加成功");
    }

    @GetMapping("/listGoods")
    public Result getListGoods() {
        List<Goods> list = goodService.listGoods();
        return Result.success(list);
    }


    //删除  商品
    @DeleteMapping("/delGoods/{id}")
    public Result deleteGoods(@PathVariable Integer id) {
         goodService.deleteGoods(id);
        return Result.success("上传成功");
    }
    @GetMapping("/modifyStatus/{id}/{status}")
    public Result modifyStatus(@PathVariable Integer id,@PathVariable Integer status) {
         goodService.modifyStatus(id,status);
        return Result.success("状态修改成功");
    }
}
